<?php
/**
 * Openid.php
 * 
 * @category    Madoqua
 * @package     Module
 * @subpackage  Auth
 */

/** base class */
require_once 'Madoqua/Form.php';

/** login validator */
require_once 'Madoqua/Validate/Openid.php';

/** controller front **/
require_once 'Zend/Controller/Front.php';

/**
 * Auth_Auth_Openid
 * 
 * login form, will accept an openid
 * 
 * @category    Madoqua
 * @package     Module
 * @subpackage  Auth
 */
class Auth_Auth_Openid extends Madoqua_Form
{
    /**
     * constructor
     * 
     * @param array $options
     */
    public function __construct($options = array())
    {
        parent::__construct();

        if (!isset($options['auth'], $options['adapter'])) {
            throw new Exception('Auth and OpenID adapter must be set for this form');
        }
        //check for consumer
        
        $this->setRouteAction(array(), 'login', true);
        
        $this->addElement('text', 'openid', array(
            'required' => true,
            'label' => 'OpenID',
            'validators' => array(
                new Madoqua_Validate_Openid($options['auth'], $options['adapter'])
                //validator using openid
            )
        ));
        //openID login

        $this->addElement('submit', 'submit', array(
            'label' => 'OpenID login'
        ));
    }
}